<template>
  <a @click="dialog = true">
    <span>修改日期</span>
    <a-modal v-model="dialog" title="请修改汇款日期" @ok="submit">
      <a-form-model :model="form">
        <a-form-model-item prop="remittanceDate" label="汇款日期：">
          <a-date-picker v-model="form.remittanceDate" />
        </a-form-model-item>
      </a-form-model>
    </a-modal>
  </a>
</template>
<script>
import moment from 'moment'
import { moneyApprove } from '@/api/common'
export default {
  name: 'changeDate',
  props: ['record'],
  data() {
    return {
      dialog: false,
      form: {
        remittanceDate: ''
      }
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    async submit() {
      this.dialog = false
      const _form = Object.assign({}, this.form)
      _form.remittanceDate = moment(this.form.remittanceDate)
        .startOf('day')
        .format('X')
      await moneyApprove(this.record.id, _form)
      this.$emit('update')
    },
    getData() {
      this.form.remittanceDate = moment(this.record.remittanceDate, 'X')
    }
  }
}
</script>
<style lang="scss" scoped></style>
